package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.THonorAttchment;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.THonorInfo;
import com.ruoyi.service.ITHonorInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 荣誉信息Controller
 * 
 * @author ruoyi
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/talent/honor")
public class THonorInfoController extends BaseController
{
    @Autowired
    private ITHonorInfoService tHonorInfoService;

    /**
     * 查询荣誉信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(THonorInfo tHonorInfo)
    {
        startPage();
        List<THonorInfo> list = tHonorInfoService.selectTHonorInfoList(tHonorInfo);
        return getDataTable(list);
    }

    /**
     * 获取荣誉信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{talentId}")
    public TableDataInfo getInfo(@PathVariable Long talentId)
    {
        List<THonorInfo> list =tHonorInfoService.selectTHonorInfoById(talentId);
        return getDataTable(list);
    }
        /**
     * 获取荣誉信息附件信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/attachment/{honorId}")
    public TableDataInfo getAttachment(@PathVariable Long honorId)
    {
        List<THonorAttchment> list =tHonorInfoService.selectAttachmentById(honorId);
        return getDataTable(list);
    }


    /**
     * 导出荣誉信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "荣誉信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, THonorInfo tHonorInfo)
    {
        List<THonorInfo> list = tHonorInfoService.selectTHonorInfoList(tHonorInfo);
        ExcelUtil<THonorInfo> util = new ExcelUtil<THonorInfo>(THonorInfo.class);
        util.exportExcel(response, list, "荣誉信息数据");
    }


}
